<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="layout :: common_header(~{::title})">
    <title>订单详情-订单总览-订单详情</title>
</head>
<body th:replace="layout :: common_body(~{::div.layui-body})">

<div class="layui-body" style="padding:15px;">
    <style>
        .dd-info p select {
            width: 250px;
            border: 1px solid #d3d3d3;
            outline: none;
            height: 25px;
        }
    </style>

    <!-- content starts -->
    <blockquote class="layui-elem-quote">订单详情
        <div class="layui-inline">
            <button type="button" id="print_btn" class="layui-btn layui-btn-primary layui-btn-sm">打印订单</button>
        </div>
    </blockquote>

    <!-- start dd-wrapper -->
    <link rel="stylesheet" href="/goods/order.css"/>
    <!--    <div class="dd-wrapper">-->
    <!--        <div class="dd-step" th:if="${orderVo.getState()>0}">-->
    <!--            <p><span th:class="${orderVo.getState() >= 1} ? 'active' : ''"><i>1</i>提交订单</span></p>-->
    <!--            <p class="line"></p>-->
    <!--            <p><span th:class="${orderVo.getState() >= 2} ? 'active' : ''"><i>2</i>买家已付款</span><em></em></p>-->
    <!--            <p class="line"></p>-->
    <!--            <p><span th:class="${orderVo.getState() >= 3} ? 'active' : ''"><i>3</i>卖家已发货</span><em></em></p>-->
    <!--            <p class="line"></p>-->
    <!--            <p><span th:class="${orderVo.getState() >= 4} ? 'active' : ''"><i>4</i>买家已收货</span><em></em></p>-->
    <!--        </div>-->
    <!--    </div>-->
    <div class="dd-wrapper" id="myElementId">


        <div class="dd-info">
            <p class="mb"><strong>订单编号：[[${orderVo.orderSn}]]</strong></p>
        </div>
        <div class="dd-info">
            <p class="mb"><strong>订单状态：</strong>
                <b th:text="${T(com.b2c.entity.pdd.EnumPddOrderStatus).getName(orderVo.order_status)}"></b>
            </p>
            <p class="mb"><strong>售后状态：</strong>
            <b th:if="${orderVo.refund_status != 0}" th:text="${T(com.b2c.entity.pdd.EnumPddOrderRefundStatus1).getName(orderVo.refund_status)}"></b>
            </p>
            <p>收件人区域：<u th:text="${orderVo.province + orderVo.city + orderVo.town}"></u></p>
            <p>收货人：[[${orderVo.receiver_name}]]</p>
            <p>收货人手机号：[[${orderVo.receiver_phone}]]</p>
            <p>收货地址：[[${orderVo.address}]]</p>


        </div>
        <div class="dd-info">
            <a href="javascript:;" th:if="${orderVo.auditStatus == 0 && orderVo.order_status == T(com.b2c.entity.pdd.EnumPddOrderStatus).WaitSend.index && orderVo.after_sales_status == 0}" style="float:right;margin:10px;" id="add_gift"
             class="layui-btn layui-btn-normal layui-btn-xs" th:attr="order_id=${orderVo.getId()},shop-id=${shop.id}">添加赠品<p><span></span></p></a>
        </div>
        <table class="dd-table">
            <tr>
                <th>商品</th>
                <th>规格</th>
                <th>SKU</th>
                <th>款号</th>
                <th>单价</th>
                <th>数量</th>

                <th>修改</th>
            </tr>
            <tr th:each="item:${orderVo.getItems()}">
                <td>
                    <div><img th:src="${item.goodsImg}">
                        <p th:text="${#strings.abbreviate(item.goodsName,18)}"></p>
                        <p th:if="${item.isGift == 1}"><span class="layui-badge">礼品</span></p>
                    </div>
                </td>
                <td>
                    <p th:text="${item.goodsSpec}"></p>
                </td>
                <td th:text="${item.goodsSpecNum}"></td>
                <td th:text="${item.goodsNum}"></td>
                <td>¥[[${item.goodsPrice}]]</td>
                <td>[[${item.quantity}]]</td>

                <td>
                    <a th:if="${orderVo.getAuditStatus()==0 && item.getIsGift()==0}" href="javascript:;" class="upd_goods" th:attr="d_item_id=${item.getId()}">修改商品</a>
                    <a th:if="${orderVo.getAuditStatus()==0 && item.getIsGift()==1}" href="javascript:;" class="order_del" th:attr="order_item_id=${item.getId()}">删除商品</a>
                </td>
            </tr>
        </table>
        <div class="dd-info">
            <p><span>实收金额：<b>¥<span th:text="${orderVo.pay_amount+orderVo.platform_discount}"></span></b></span></p>
            <p><span>含物流费用：<b>¥[[${orderVo.postage}]]</b></span></p>
        </div>
        <div class="dd-info">
            <a href="javascript:;" style="background:#39c;color:#fff;float:right;margin:10px;" class="layui-btn confirm"
               th:attr="order_id=${orderVo.getId()},shop-id=${shop.id}" th:if="${orderVo.auditStatus == 0 && orderVo.refund_status == 1}">确认订单<p><span></span></p></a>
        </div>
    </div>
    <div class="dd-wrapper">
        <div class="dd-log">
            <h3>物流信息</h3>
            <ul>
                <li th:each="vo:${data}">
                    <i></i><span>物流跟踪:[[${vo.time}]]</span><span>[[${vo.context}]]</span></li>
            </ul>
        </div>
    </div>
    <!-- end dd-wrapper -->
    <script type="text/template" id="edit_good_sku">
        <div class="T-box">
            <form method="post">
                <p id="new_good_sku"></p>
            </form>
        </div>
    </script>

    <script src="/jquery-3.3.1.min.js"></script>
    <script src="/jQuery.print.min.js"></script>
    <script>
        layui.use(['laydate', 'jquery', 'form', 'layer'], function () {
            var laydate = layui.laydate;
            var $ = layui.jquery;
            var form = layui.form;
            var layer = layui.layer;
            laydate.render({
                elem: '#startTime'
            });
            laydate.render({
                elem: '#endTime'
            });


            $(function () {
                $("#print_btn").click(function () {
                    $.print("#myElementId" /*, options*/);
                })

                //变更商品
                $(".upd_goods").click(function () {
                    var $this = $(this);
                    var orderItemId =  $this.attr("d_item_id");
                    var shopId =  '[[${shopId}]]';
                    //确认订单iframe层
                    layer.open({
                        type: 2,
                        title: '修改订单商品',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['1100px', '650px'],
                        content: '/pdd/order_item_upd_goods?orderItemId=' + orderItemId +'&shopId='+shopId//iframe的url
                    });

                })


                //确认订单
                $(".confirm").click(function () {
                    var $this = $(this);
                    var orderId = $(this).attr("order_id");
                    var shopId = $(this).attr("shop-id");
                    //确认订单iframe层
                    layer.open({
                        type: 2,
                        title: '订单确认',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['480px', '650px'],
                        content: '/pdd/order_confirm?orderId=' + orderId + "&shopId=" + shopId //iframe的url
                    });


                });

                //添加赠品
                $("#add_gift").click(function () {
                    var $this = $(this);
                    var orderId = $this.attr("order_id");
                    var shopId = $(this).attr("shop-id");
                    //确认订单iframe层
                    layer.open({
                        type: 2,
                        title: '添加订单赠品',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['1100px', '650px'],
                        content: '/pdd/add_order_gift?orderId=' + orderId+'&shopId='+ shopId //iframe的url
                    });
                })
                $(".order_del").click(function () {
                    var orderItemId = $(this).attr("order_item_id");
                    $.ajax({
                        url: "/ajax_pdd/order_item_del",
                        type: "POST",
                        dataType: "JSON",
                        contentType: 'application/json',
                        data: orderItemId,
                        success: function (res) {
                            if (res.code == 0) {
                                alert("删除成功");
                                location.reload();
                            }
                        }
                    })
                });
            });//jquery END
        });
    </script>

</div>


</body>
<html>
